package com.czk.model.combile.prictice;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/7/29 22:33
 */
public class Grandpa extends Person {
    // 内部为儿子集合
    List<Person> sons=new ArrayList<>();

    public Grandpa(String name, int age) {
        super(name, age);
    }

    @Override
    protected void add(Person person) {
        sons.add(person);
    }

    @Override
    protected void print() {
        System.out.println(this.getName());
        for (Person son : sons) {
            System.out.println(son.getName());
            son.print();
        }
    }
}
